`:top
`!Concurrent Pascal`! is a `F33f`_`[programming language`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Programming_language]`_`f designed by `F33f`_`[Per Brinch Hansen`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Per_Brinch_Hansen]`_`f for writing `F33f`_`[concurrent computing`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Concurrent_computing]`_`f programs such as `F33f`_`[operating systems`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Operating_system]`_`f and `F33f`_`[real-time computing`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Real-time_computing]`_`f monitoring systems on `F33f`_`[shared memory`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Shared_memory]`_`f computers.`:cite-ref-1[`F5bf`_`[1`#cite-note-1]`_`f]
A separate language, `*Sequential Pascal`*, is used as the language for applications programs run by the operating systems written in Concurrent Pascal. Both languages are extensions of `F33f`_`[Niklaus Wirth`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Niklaus_Wirth]`_`f's `F33f`_`[Pascal`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Pascal_(programming_language)]`_`f, and share a common threaded code `F33f`_`[interpreter`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Interpreter_(computing)]`_`f.`:cite-ref-0-2-0[`F5bf`_`[2`#cite-note-0-2]`_`f] The following describes how Concurrent Pascal differs from Wirth's Pascal.
>>Contents
• `F0af`_`[Language description`#language-description]`_`f
• `F0af`_`[Example`#example]`_`f
• `F0af`_`[References`#references]`_`f
-─
>>Language description
Several constructs in Pascal were removed from Concurrent Pascal for simplicity and security:`:cite-ref-0-2-1[`F5bf`_`[2`#cite-note-0-2]`_`f]
• Variant records
• `F33f`_`[Goto`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Goto]`_`f statement, and labels
• `F33f`_`[Procedures as parameters`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Subroutine]`_`f
• `F33f`_`[Packed arrays`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Data_structure_alignment]`_`f
• `F33f`_`[Pointer types`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Pointer_(computer_programming)]`_`f
• File types, and associated standard `F33f`_`[input/output`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Input/output]`_`f procedures
These omissions make it possible to guarantee, by a combination of compile-time checks and minimal run-time checking in the threaded-code interpreter, that a program can not damage itself or another program by addressing outside its allotted space.
Concurrent Pascal includes class, monitor, and process data types. Instances of these types are declared as variables, and initialized in an `B100`F9d9`F33f`_`[init`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Init]`_`f`f`b statement.
Classes and monitors are similar: both package private variables and procedures with public procedures (called procedure entries). A class instance can be used by only one process, whereas a monitor instance may be shared by processes. Monitors provide the only mechanism for interprocess communication in a Concurrent Pascal program.
Only one process can execute within a given monitor instance at a time. A built in data type, the queue, together with operations `B100`F9d9delay`f`b and `B100`F9d9continue`f`b, are used for scheduling within monitors. Each variable of type queue can hold one process. If many processes are to be delayed in a monitor, multiple queue variables, usually organized as an array, must be provided. The single process queue variable gives a monitor full control over medium-term scheduling, but the programmer is responsible for unblocking the correct process.
A process, like a class or monitor, has local variables, procedures, and an initial statement, but has no procedure entries. The initial statement ordinarily executes forever, calling local procedures, class procedures, and monitor procedures. Processes communicate through monitor procedures. Language rules prevent deadlock by imposing a hierarchy on monitors. But nothing can prevent a monitor from erroneously forgetting to unblock a delayed process (by not calling continue) so the system can still effectively hang up through programming errors.
The configuration of processes, monitors, and classes in a Concurrent Pascal program is normally established at the start of execution, and is not changed thereafter. The communication paths between these components are established by variables passed in the `B100`F9d9init`f`b statements, since class and monitor instance variables cannot be used as procedure parameters.
>>Example
The following example shows the declaration of a simple monitor, and its use by two communicating processes.
`B100`F9d9type`f`b
`B100`F9d9 "Bounded buffer monitor"`f`b
`B100`F9d9 buffer = Monitor`f`b
`B100`F9d9 var`f`b
`B100`F9d9 saved : Integer; "saved item is an integer"`f`b
`B100`F9d9 fullq, emptyq : Queue; "used by only two processes"`f`b
`B100`F9d9 full : Boolean; "true if an item is saved:"`f`b
`B100`F9d9`f`b
`B100`F9d9 "Puts item in buffer"`f`b
`B100`F9d9 procedure entry put(item : Integer);`f`b
`B100`F9d9 begin`f`b
`B100`F9d9 if full then`f`b
`B100`F9d9 delay(fullq); "block if full"`f`b
`B100`F9d9 saved := item; "save the item"`f`b
`B100`F9d9 full := true; "mark as full"`f`b
`B100`F9d9 continue(emptyq) "unblock consumer"`f`b
`B100`F9d9 end;`f`b
`B100`F9d9`f`b
`B100`F9d9 "Gets item from the buffer"`f`b
`B100`F9d9 procedure entry get(var item : Integer);`f`b
`B100`F9d9 begin`f`b
`B100`F9d9 if not full then`f`b
`B100`F9d9 delay(emptyq); "block if empty"`f`b
`B100`F9d9 item := saved; "get the item"`f`b
`B100`F9d9 full := false; "mark as not full"`f`b
`B100`F9d9 continue(fullq) "unblock producer"`f`b
`B100`F9d9 end;`f`b
`B100`F9d9`f`b
`B100`F9d9 "Initialize the monitor"`f`b
`B100`F9d9 begin`f`b
`B100`F9d9 full := false`f`b
`B100`F9d9 end;`f`b
`B100`F9d9`f`b
`B100`F9d9 "Producer uses a buffer"`f`b
`B100`F9d9 producer = process(pass : Buffer);`f`b
`B100`F9d9 var item : Integer;`f`b
`B100`F9d9 begin`f`b
`B100`F9d9 cycle "execute in a loop forever"`f`b
`B100`F9d9 "produce an item"`f`b
`B100`F9d9 pass.put(item) "pass an item to the monitor"`f`b
`B100`F9d9 end`f`b
`B100`F9d9 end;`f`b
`B100`F9d9`f`b
`B100`F9d9 "Consumer uses a buffer"`f`b
`B100`F9d9 consumer = process(pass : Buffer);`f`b
`B100`F9d9 var item : Integer;`f`b
`B100`F9d9 begin`f`b
`B100`F9d9 cycle`f`b
`B100`F9d9 pass.get(item); "get an item from the monitor"`f`b
`B100`F9d9 "consume the item"`f`b
`B100`F9d9 end`f`b
`B100`F9d9 end;`f`b
`B100`F9d9`f`b
`B100`F9d9"declare instances of the monitor, producer, and consumer"`f`b
`B100`F9d9"give the producer and consumer access to the monitor"`f`b
`B100`F9d9var`f`b
`B100`F9d9 pass : Buffer;`f`b
`B100`F9d9 prod : Producer;`f`b
`B100`F9d9 cons : Consumer;`f`b
`B100`F9d9begin`f`b
`B100`F9d9 init pass, "initialize the monitor"`f`b
`B100`F9d9 prod(pass), "start the producer process"`f`b
`B100`F9d9 cons(pass) "start the consumer process"`f`b
`B100`F9d9end.`f`b
>>References
`:cite-note-1`!1.`! `F0af`_`[↑`#cite-ref-1]`_`f `:citerefbrinch-hansen1975`aBrinch Hansen, Per (June 1975). "The programming language Concurrent Pascal" (PDF). `*IEEE Transactions on Software Engineering`* (2): 199–207. `F33f`_`[doi`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Doi_(identifier)]`_`f:10.1109/tse.1975.6312840.
`:cite-note-0-2`!2.`! `F0af`_`[↑`#cite-ref-0-2-0]`_`f `:citerefbrinch-hansen1977`aBrinch Hansen, Per (1977). `*The Architecture of Concurrent Programs`*. Prentice Hall. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 978-0-13-044628-2.
`c`F0af`_`[↑ Back to top`#top]`_`f`a